home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1782 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  39 lines

  1. Path: news.dadd.ti.com!newsmgrs@dadd.ti.com
  2. From: Sudheer Vemulapalli <sudheer@dadd.ti.com>
  3. Newsgroups: comp.lang.c
  4. Subject: renaming file names from within C!
  5. Date: 16 Jan 1996 22:12:27 GMT
  6. Organization: Texas Instruments
  7. Message-ID: <4dh7sb$6de@hammerhead.dadd.ti.com>
  8. NNTP-Posting-Host: roadrunner.dadd.ti.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.1N (X11; I; SunOS 5.3 sun4m)
  13. X-URL: news:comp.lang.c
  14.  
  15. Hello Netters,
  16.  
  17. I have a question. Please let me know how to do the following.
  18.  
  19. How can i move/rename a file in the UNIX system from within a C program.
  20.  
  21. Suppose i have two strings "a" and "b".
  22.  
  23. char *a, *b;
  24.  
  25. which contain the two strings. and let's say that a file exists with its name
  26. same as the string in "b". How can i rename it or mv it so that the file's name
  27. becomes same as string in "a".
  28.  
  29. Is there a short way of doing it rather than creating another file with new
  30. name and copying the contents of the old file into the new file and then
  31. removing the old file. 
  32.  
  33. Thankx in advance.
  34.  
  35. Bye,
  36. -- 
  37. Sudheer K. Vemulapalli
  38.  
  39.